﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace WebApplication1
{
    public partial class NewsRead : System.Web.UI.Page
    {
        public string strNewsContent
        {
            get;
            set;
        }
        public string strTitle
        {
            get;
            set;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["newsid"]==null)
            {
                Response.Write("<script>alert('请选择浏览的新闻');location.href='NavigationResult.aspx';</script>");
                return;
            }
            if (!IsPostBack)
            {
                int iNewsId = Convert.ToInt32(Request.QueryString["newsid"]);
                DataTable dt = new DataTable();
                SQLHelper.getNewsById(iNewsId, out dt);

                strTitle = dt.Rows[0]["Title"].ToString();
                lblUploadTime.Text = dt.Rows[0]["UploadTime"].ToString();
                lblUserName.Text = dt.Rows[0]["UserName"].ToString();
                lblViewCount.Text = dt.Rows[0]["ViewCount"].ToString();
                strNewsContent = dt.Rows[0]["NewsContent"].ToString();
                SQLHelper.updateNewsViewCountById(iNewsId);
                Page.DataBind();
            }


        }
    }
}